function guid(){
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
    var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
    return v.toString(16);
  }).toLowerCase();
}


module.exports = class extends think.Controller {
  async __before() {
    let key = this.cookie('session_id');
    if(!key){
      key = guid();
      this.cookie('session_id',key, { maxAge: 365 * 24 * 60 * 60 * 1000, signed: false });
    }


  }
};
